﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace comm.lib
{
    [Serializable]
    public abstract class MapEvent
    {
        static List<Type> _subTypeList = new List<Type>();
        static MapEvent()
        {
            var type = typeof(MapEvent);
            var types = type.Assembly.GetTypes();
            foreach (var type2 in types)
            {
                if (type2.IsSubclassOf(type))
                {
                    _subTypeList.Add(type2);
                }
            }
        }
        public static Type[] GetSubTypes()
        {
            return _subTypeList.ToArray();
        }

        #region MoveToSpace
        [Serializable]
        public class MoveToSpace : MapEvent
        {
            private string _spaceId = null;
            public string SpaceId
            {
                get
                {
                    if (_spaceId == null)
                    {
                        _spaceId = "";
                    }
                    return _spaceId;
                }
                set { _spaceId = value; }
            }

            public int LocX { get; set; }
            public int LocY { get; set; }

            public override string ToString()
            {
                return "mTo:" + SpaceId + "(" + LocX + "," + LocY + ")";
            }
        }
        #endregion

        #region MoveToLocLabel
        [Serializable]
        public class MoveToLocLabel : MapEvent
        {
            private string _spaceId = null;
            public string SpaceId
            {
                get
                {
                    if (_spaceId == null)
                    {
                        _spaceId = "";
                    }
                    return _spaceId;
                }
                set { _spaceId = value; }
            }

            private string _mapObjKey = null;
            public string MapObjKey
            {
                get
                {
                    if (_mapObjKey == null)
                    {
                        _mapObjKey = "";
                    }
                    return _mapObjKey;
                }
                set { _mapObjKey = value; }
            }

            public override string ToString()
            {
                return "mTo:" + SpaceId + "(" + MapObjKey + ")";
            }
        }
        #endregion

        #region CommandType
        [Serializable]
        public enum CommandType
        {
            UNIT_FACTORY = 0,
            LAB_ROOM = 1,
            LOC_LABEL = 2,
            NEW_HERO_LOC = 3,

            D1 = 100,
            D2 = 101,
            D3 = 102
        }
        #endregion

        #region Command
        [Serializable]
        public class Command : MapEvent
        {
            public static string[] GetCommandTypes()
            {
                return comm.EnumHelper.GetNames(typeof(CommandType));
            }

            public CommandType Type { get; set; }

            public override string ToString()
            {
                return "cmd:" + Type.ToString();
            }
        }
        #endregion
    }
}
